﻿@using Chaine.Models
@model IList<EventModels>
@{
    ViewBag.Title = "Events";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section maincontent{
    @if (TempData["create-success"] != null)
    {
        <!--创建成功-->
        <div class="alert alert-success">
            <a class="close" data-dismiss="alert" href="#">×</a> Create event successfully!
        </div>
    }
    @if (TempData["update-success"] != null)
    {
        <!--修改成功-->
        <div class="alert alert-success">
            <a class="close" data-dismiss="alert" href="#">×</a> Update event successfully!
        </div>
    }
    @if (TempData["delete-success"] != null)
    {
        <!--删除成功-->
        <div class="alert alert-success">
            <a class="close" data-dismiss="alert" href="#">×</a> Delete event successfully!
        </div>
    }
    <h2>
        @ViewBag.Title</h2>
    <p>
        @Html.ActionLink("Create new event", "create", "AdminEvent", null, new { @class = "btn" })
    </p>
    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <td>
                    No.
                </td>
                <td>
                    Title
                </td>
                <td>
                    Start DateTime
                </td>
                <td>
                    End DateTime
                </td>
                <td>
                </td>
            </tr>
        </thead>
        <tbody>
            @foreach (var e in Model)
            {
                var index = Model.IndexOf(e);
                <tr>
                    <td>@(index + 1)
                    </td>
                    <td>
                        @e.Title
                    </td>
                    <td>@e.StartDateTime.ToString("MM'/'dd'/'yyyy HH:mm")
                    </td>
                    <td>@e.EndDateTime.ToString("MM'/'dd'/'yyyy HH:mm")
                    </td>
                    <td>
                        <div class="btn-group">
                            <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Action <span class="caret">
                            </span></a>
                            <ul class="dropdown-menu">
                                <li>@Html.ActionLink("Photos", "index", "AdminPhoto", new { eventid = e.Id.ToString() }, null)</li>
                                <li>@Html.ActionLink("Edit", "edit", new { id = e.Id })</li>
                                <li class="divider"></li>
                                <li>@Html.ActionLink("Delete", "delete", new { id = e.Id })</li>
                            </ul>
                        </div>
                    </td>
                </tr>
   
            }
        </tbody>
    </table>
}
@section sidebar{
    @Html.Partial("~/views/shared/_adminsidebar.cshtml")
}
